/*
 * ConsoleInput.java
 * 
 * Team Dovahkiin:
 * Major Bruno, Matthew Selfors
 * 
 * This class provides a dialogue window for the user to enter input
 * from the KBD.
 */

package phaseIII;

import java.awt.Color;

import javax.swing.JOptionPane;

import phaseII.CPU;

/**
 * A GUI pane for entering user input.
 * 
 * @author Major Bruno
 * @author Matthew Selfors
 * @version 1.0
 */
@SuppressWarnings("serial")
public class ConsoleInput extends JOptionPane {

	/**
	 * Captures the user's input.
	 */
	private String input;
	
	/**
	 * Takes a reference to the cpu, initializes all fields.
	 * 
	 * @param the_cpu a cpu object to call methods on.
	 */
	public ConsoleInput(final CPU the_cpu) {
		super();
		setBackground(Color.BLACK);
		setForeground(Color.GREEN);
		while (input == null) {
			input = showInputDialog(null, "Enter input here:", "Console Input", JOptionPane.PLAIN_MESSAGE);
			if (input == null) {
				showMessageDialog(null, "You must enter input!", "Invalid input!", JOptionPane.ERROR_MESSAGE);
			}
		}
		the_cpu.setKeyboardInput(input);
	}
}
